<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.property/TR/html4/loose.dtd">
<%@taglib prefix="my"  uri="/WEB-INF/tag/my-tag.tld"%>
<html>
<head>
<%@include file="/header.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文件列表页面</title>
<script type="text/javascript">
function refGrid(){
	$('#datagridtable').treegrid("clearChecked");
	$('#datagridtable').treegrid("options").url='${base}sysFile/fileList?'+$("form").serialize();
	$('#datagridtable').treegrid("load");  
}
   
  $(function(){
	  $("#searchbtn").click(function(){refGrid();});
	  
	  $('#datagridtable').treegrid({    
		    singleSelect:false,
		    collapsible:false,
		    url:'${base}sysFile/fileList?'+$("form").serialize(),
		    method:'post',
		    pagination:true,
		    toolbar:'#toolbar',
			pageSize:20,
			multiSort:true,
			rownumbers:true,
			border:false,
			animate:true,
			idField:'id',
			autoRowHeight:false,
			fitColumns: true,
		    columns:[[    
		        {field:'id',checkbox:true},    
		        {field:'originalName',title:'原名称',width:150,sortable:true},    
		        {field:'uploader',title:'上传人',width:80,sortable:true},
		        {field:'uploadTime',title:'上传时间',width:80,sortable:true,formatter:formatDateTime},
		        {field:'newName',title:'存储名称',width:150,sortable:true},
		        {field:'storagePath',title:'存储路径',width:200,sortable:true}
		    ]]
		});
      
	  $("#uploadBtn").click(function(){
    	  myDialog({title:"上传文件",src:"${base}sysFile/addPage",width:900,height:600,callBack:refGrid});
      });
	  
      $("#delBtn").click(function(){
    	  var selOpts =$('#datagridtable').datagrid("getChecked");
			if(selOpts.length==0){
				myAlert("错误信息","请选择需要删除的记录！","e");
				return;
				}
			ids=[];
			$.each(selOpts,function(i,v){
				     ids.push(v.id);
				});
			myConfirm("提示信息","确定删除选中的数据吗?",function(r){
                 if(r){
                	 myAjax({url:"${base}sysFile/delFileByIds",data:{"ids":ids},  
                    	 success:function(data){
                              if(data.error=='0')
                            	      refGrid();
                              else
                            	  myAlert("错误信息",data.msg,"e");   
                    	 }}); 
              }
			});
      });
      $("#detailBtn").click(function(){
    	  var selOpts =$('#datagridtable').datagrid("getChecked");
			if(selOpts.length==0||selOpts.length>1)
				myAlert("错误信息","请选择一条记录！","e");
			else
			  myDialog({title:"查看用户",src:"${base}sysFile/detailPage?id="+selOpts[0].id,width:600,height:300,
				  callBack:function(){
				  $('#datagridtable').datagrid("clearChecked");}});
      });
});
</script>
</head>
<body>
   <div id="toolbar">
  <div class="toolbar_searchcondition">
   <form class="easyui-form" action="${base}sysFile/fileList"  method="post">
	  原名称: <input class="easyui-textbox" name="params['originalName']" type="text"/>&nbsp;
	  <!-- 上传时间: <input class="easyui-textbox"  name="params['uploadTimeStart']"  />
	  至&nbsp;<input class="easyui-textbox"  name="params['uploadTimeEnd']"  /> -->
		   <a href="#" class="easyui-linkbutton searchbtn" iconCls="icon-search" id="searchbtn">查询</a>
		</form>
		</div>
		<div class="toolbar_btns">
		<a href="#" class="easyui-linkbutton" iconCls="icon-page-white-get " plain="true" id="uploadBtn">上传</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="delBtn">删除</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" id="detailBtn">查看</a>
		</div>
   </div>
	  <table id="datagridtable"  style="width:1200px;height:500px" fit="true"></table>
</body>
</html>